//
//  FFMainViewController.swift
//  SwiftWeiBo
//
//  Created by 乔庆芳 on 16/4/10.
//  Copyright © 2016年 乔庆芳. All rights reserved.
//

import UIKit

class FFMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let mainTabBar=FFBaseTabBar()
        
        mainTabBar.closure={
        
            print("点击了加号")
        }
        setValue(mainTabBar, forKey: "tabBar")
        
        setUpChildsViewController()
        

    }
    
    //私有方法
    private func setupChildViewController(Controller :UIViewController,imageName :String,titleName :String){
    
        //wo
        
        Controller.title=titleName
        //设置标题文字的颜色
        Controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: UIControlState.Selected)
        Controller.tabBarItem.image=UIImage(named: imageName)
        //拼接点击时的名字
        Controller.tabBarItem.selectedImage=UIImage(named: imageName+"_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        addChildViewController(UINavigationController(rootViewController: Controller))
        


    }
    //私有方法
    private func setUpChildsViewController(){
    
        setupChildViewController(FFHomeTableViewController(), imageName: "tabbar_home", titleName: "首页")
        setupChildViewController(FFDiscoverTableViewController(), imageName: "tabbar_discover", titleName: "查找")
        setupChildViewController(FFMessageTableViewController(), imageName: "tabbar_message_center", titleName: "消息")
        setupChildViewController(FFProfileTableViewController(), imageName: "tabbar_profile", titleName: "我")
    }

    
}
